<?php

require_once("../../controllers/init.php");
require_once($FILE_SYSTEM_ROOT."/controllers/authentication.php");
require_once($FILE_SYSTEM_ROOT."/model/classes/utilities/UserGroups.php");

$userID = 0;

if (isset($_POST['ModifyUserID']))
	$userID = $_POST['ModifyUserID'];

$user = $GLOBALS['USERS'][$userID];

//set up group options
$groupsObj = new UserGroups();
$groups = $groupsObj->getGroups();

//print_r($groups);
//print_r ("Size = ".sizeof($groups));


$groupsSelect = "<select class=\"admin-modifyusers-user-edit-value-text\" id=\"admin-modifyusers-user-edit-value-groupname\">\n";
foreach ($groups as $key=>$groupvalue)
{
//	print($key."".$groupvalue." \n");
	$select = "";
	if($user['SnapUserGroupID']==$key)$select="selected ";
	$groupsSelect .= "<option value=\"".$key."\" ".$select.">".$groupvalue."</option>\n";
}
$groupsSelect .= "</select>\n";

//print_r($user);
?>


<input type="hidden" id="admin-modifyusers-user-edit-value-SnapUserID" value="<?php echo $userID; ?>"></input>

<div class = "admin-modifyusers-user-edit-title">Long Name</div>
<div class = "admin-modifyusers-user-edit-value"><input type="text" class="admin-modifyusers-user-edit-value-text" id="admin-modifyusers-user-edit-value-longname" value="<?php echo $user['LongName'];?>"></input></div>

<div class = "admin-modifyusers-user-edit-title">Short Name</div>
<div class = "admin-modifyusers-user-edit-value"><input type="text" class="admin-modifyusers-user-edit-value-text" id="admin-modifyusers-user-edit-value-shortname" value="<?php echo $user['ShortName'];?>"></input></div>

<div class = "admin-modifyusers-user-edit-title">Password</div>
<div class = "admin-modifyusers-user-edit-value"><input type="text" class="admin-modifyusers-user-edit-value-text" id="admin-modifyusers-user-edit-value-password" value="<?php echo $user['Password'];?>"></input></div>

<div class = "admin-modifyusers-user-edit-title">Email</div>
<div class = "admin-modifyusers-user-edit-value"><input type="text" class="admin-modifyusers-user-edit-value-text" id="admin-modifyusers-user-edit-value-email" value="<?php echo $user['email'];?>"></input></div>

<div class = "admin-modifyusers-user-edit-title">Group</div>
<div class = "admin-modifyusers-user-edit-value"><?php echo $groupsSelect; ?></div>


